//package com.yunhe.device.controller.device;
//
//import com.yunhe.device.domain.device.Analog;
//import com.yunhe.device.domain.device.Device;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.device.DeviceService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * 设备Controller
// * @author liuronglei
// */
//@Api(value = "device", description = "设备维护", tags = {"Device"})
//@RestController
//@RequestMapping("/devices")
//public class DeviceController {
//    @Autowired
//    private DeviceService deviceService;
//
//    /**
//     * 新增设备
//     * @param energyUnitId 能量单元ID
//     * @param device 设备对象
//     */
//    @ApiOperation("新增设备")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "energyUnitId", value = "能量单元ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestParam("energyUnitId") Long energyUnitId,
//            @RequestBody Device device)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        Device newDevice = deviceService.createDevice(energyUnitId, device);
//        return new ResponseEntity<>(new ResultObject<>(newDevice), HttpStatus.OK);
//    }
//
//    /**
//     * 批量新增设备
//     * @param energyUnitId 能量单元ID
//     * @param domainList 设备对象列表
//     */
//    @ApiOperation("批量新增设备")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "energyUnitId", value = "能量单元ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestParam("energyUnitId") Long energyUnitId,
//            @RequestBody DomainList<Device> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        Iterable<Device> newDevices = deviceService.createDevice(energyUnitId, domainList.getList());
//        return new ResponseEntity<>(new ResultObject<>(newDevices), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除设备
//     * @param energyUnitId 能量单元ID
//     * @param id 设备ID
//     */
//    @ApiOperation("根据ID删除设备")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "energyUnitId", value = "能量单元ID", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "id", value = "设备ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @RequestParam("energyUnitId") Long energyUnitId,
//            @PathVariable("id") Long id) {
//        deviceService.deleteDevice(energyUnitId, id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新设备（更新全部字段）
//     * @param id ID
//     * @param device 设备对象
//     */
//    @ApiOperation("更新设备（更新全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody Device device)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        device.setId(id);
//        Device newDevice = deviceService.updateDevice(device);
//        return new ResponseEntity<>(new ResultObject<>(newDevice), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备ID获得设备对象
//     * @param id ID
//     */
//    @ApiOperation("根据ID获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        Device device = deviceService.findByDeviceId(id);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据电站ID获得设备对象
//     * @param stationId 电站ID
//     */
//    @ApiOperation("根据电站ID获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "stationId", value = "电站ID", required = true, dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/byStation", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByStation(
//            @RequestParam("stationId") Long stationId) {
//        Iterable<Device> device = deviceService.findByStationId(stationId);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据电站ID获得设备对象（带分组）
//     * @param stationId 电站ID
//     */
//    @ApiOperation("根据电站ID获得设备对象（带分组）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "stationId", value = "电站ID", required = true, dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/byStationForGroup", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByStationForGroup(
//            @RequestParam("stationId") Long stationId) {
//        Map<String, List<Object>> device = deviceService.findByStationIdForGroup(stationId);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据电站ID和设备类型获得设备对象
//     * @param stationId 电站ID
//     * @param type 设备类型
//     */
//    @ApiOperation("根据电站ID和设备类型获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "stationId", value = "电站ID", required = true, dataType = "Long", paramType = "query"),
//            @ApiImplicitParam(name = "type", value = "设备类型", required = true, dataType = "String", paramType = "query")
//    })
//    @RequestMapping(value = "/byStationAndType", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByStationAndType(
//            @RequestParam("stationId") Long stationId,
//            @RequestParam("type") String type) {
//        Iterable<Device> device = deviceService.findByStationIdAndType(stationId, type);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据能量单元ID获得设备对象
//     * @param energyUnitId 能量单元ID
//     */
//    @ApiOperation("根据能量单元ID获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "energyUnitId", value = "能量单元ID", required = true, dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/byEnergyUnit", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByEnergyUnit(@RequestParam("energyUnitId") Long energyUnitId) {
//        Iterable<Device> device = deviceService.findByEnergyUnitId(energyUnitId);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据能量单元ID获得设备对象（带分组）
//     * @param energyUnitId 能量单元ID
//     */
//    @ApiOperation("根据能量单元ID获得设备对象（带分组）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "energyUnitId", value = "能量单元ID", required = true, dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/byEnergyUnitForGroup", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByEnergyUnitForGroup(
//            @RequestParam("energyUnitId") Long energyUnitId) {
//        Map<String, List<Object>> device = deviceService.findByEnergyUnitIdForGroup(energyUnitId);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据能量单元ID和设备类型获得设备对象
//     * @param energyUnitId 能量单元ID
//     * @param type 设备类型
//     */
//    @ApiOperation("根据能量单元ID和设备类型获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "energyUnitId", value = "能量单元ID", required = true, dataType = "Long", paramType = "query"),
//            @ApiImplicitParam(name = "type", value = "设备类型", required = true, dataType = "String", paramType = "query")
//    })
//    @RequestMapping(value = "/byEnergyUnitAndType", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByEnergyUnitAndType(
//            @RequestParam("energyUnitId") Long energyUnitId,
//            @RequestParam("type") String type) {
//        Iterable<Device> device = deviceService.findByEnergyUnitIdAndType(energyUnitId, type);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据单位ID获得设备对象
//     * @param firmId 单位ID
//     */
//    @ApiOperation("根据单位ID获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "firmId", value = "单位ID", required = true, dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/byFirm", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByFirm(
//            @RequestParam("firmId") Long firmId) {
//        Iterable<Device> device = deviceService.findByFirmId(firmId);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码获得设备对象
//     * @param code 代码
//     */
//    @ApiOperation("根据代码获得设备对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByCode(
//            @PathVariable("code") Long code) {
//        Device device = deviceService.findByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(device), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备ID获得点号列表
//     * @param id ID
//     */
//    @ApiOperation("根据设备ID获得点号列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/analogs/", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getAnalogs(
//            @PathVariable("id") Long id) {
//        Iterable<Analog> analogs = deviceService.findAnalogs(id);
//        return new ResponseEntity<>(new ResultObject<>(analogs), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备ID和子设备标签以及点号类型获得点号列表
//     * @param id 设备ID
//     * @param childType 子设备标签
//     * @param pdtCodeList 点号类型
//     */
//    @ApiOperation("根据设备ID和子设备标签以及点号类型获得点号列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "childType", value = "子设备标签", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "pdtCodeList", value = "点号类型", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/childAnalogs/", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findChildAnalogs(
//            @PathVariable("id") Long id,
//            @RequestParam("childType") String childType,
//            @RequestParam("pdtCodeList") List<Long> pdtCodeList) {
//        Iterable<Analog> analogs = deviceService.findChildAnalogs(id, childType, pdtCodeList);
//        return new ResponseEntity<>(new ResultObject<>(analogs), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备ID获得其连接关系的指定设备类型的设备列表
//     * @param id 设备ID
//     * @param type 设备类型
//     */
//    @ApiOperation("根据设备ID获得其连接关系的指定设备类型的设备列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "type", value = "设备标签", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/connectTo/", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findByConnectRelation(
//            @PathVariable("id") Long id,
//            @RequestParam("type") String type) {
//        List<Device> devices = deviceService.findByConnectRelation(id, type);
//        return new ResponseEntity<>(new ResultObject<>(devices), HttpStatus.OK);
//    }
//}